home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / zendisk1.zip / LST9-13.ASM < prev    next >
Assembly Source File  |  1990-02-15  |  979b  |  37 lines

  1. ;
  2. ; *** Listing 9-13 ***
  3. ;
  4. ; Adds together two 64-bit memory variables, taking
  5. ; advantage of the fact that neither INC nor LOOP affects
  6. ; the Carry flag.
  7. ;
  8. ; Note: This is a sample code fragment, and is not intended
  9. ; to either be run under the Zen timer or assembled as a
  10. ; standalone program.
  11. ;
  12.     jmp    Skip
  13. ;
  14. MemVar1        db    2, 0, 0, 0, 0, 0, 0, 0
  15. MEM_VAR_LEN    equ    ($-MemVar1)
  16. MemVar2        db    0feh, 0ffh, 0ffh, 0ffh, 0, 0, 0, 0
  17. ;
  18. Skip:
  19.     mov    si,offset MemVar1 ;set up memory variable
  20.     mov    di,offset MemVar2 ; pointers
  21.     mov    ax,[si]        ;add the first words
  22.     add    [di],ax        ; together
  23.     mov    cx,(MEM_VAR_LEN/2)-1
  24.                 ;we'll add together the
  25.                 ; remaining 3 words in
  26.                 ; each variable
  27. AdditionLoop:
  28.     inc    si
  29.     inc    si        ;point to next word
  30.     inc    di        ; (doesn't affect Carry
  31.     inc    di        ; flag)
  32.     mov    ax,[si]        ;add the next words
  33.     adc    [di],ax        ; together-C flag still set
  34.                 ; from last addition
  35.     loop    AdditionLoop    ;add the next word of each
  36.                 ; variable together
  37.